<template>
<!-- 	<el-select v-model="Type" placeholder="请选择" @change="newsPage">
		<el-option v-for="(item,index) in svData" :key="index" :value="item.name" />
	</el-select> -->

	<uni-section style="min-width:10rem;" :clear="true" title="选择服务器" type="line">
		<uni-data-select v-model="Type" :placeholder="TypeName" :localdata="data" @change="newsPage"></uni-data-select>
	</uni-section>
	
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "servicelist",
		data() {
			return {
				Type: "",
				TypeName: "请选择服务器~",
				data: []
			};
		},
		methods: {
			test() {
				let arr =[...this.svData]
				arr.forEach(res => {
					if (this.besrurl == res.url) {
						this.TypeName = res.name
					}
				})
			},
			newsPage() {
				setTimeout(() => {
					uni.redirectTo({
						"url": "/dst/service/home/list"
					})
				}, 1000)
			},
			...mapMutations('http', ['setBesrUrl'])
		},
		created() {
			let arr = []
			this.svData.forEach(item=>{
				arr.push({
					text:item.name,
					value:item.url
				})
			})
			this.data = arr
			this.test()
		},
		watch: {
			Type(val) {
				// console.log('aaaaa',val);
				this.setBesrUrl(val)
			}
		},
		computed: {
			...mapState('http', ['besrurl', 'svData'])
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
	}

	.uni-breadcrumb-x {
		width: 100%;
		flex: 1;
		justify-content: end;
		display: flex;
		padding: 0 5px;
		min-height: 55px;
		line-height: 55px;
		align-items: center;

		.url-box {
			display: flex;
			justify-content: right;
			align-items: center;

			.url-box-item {
				display: inline-block;
				padding: 0px 5px;
				border: 1px solid #858585;
				text-align: center;
				height: 25px;
				line-height: 25px;
				box-sizing: border-box;
			}
		}
	}
</style>